module nade.chain;


class Chain(T) {
	T			data;

	this(Chain!(T) next = null)
	{
		_next = next;
	}

	Chain!(T) next()
	{
		if(_next is null)
			return null;

		return _next = _next.unwind;
	}

	Chain!(T) unwind()
	{
		return this;
	}

	void append(Chain!(T) rhs)
	{
		if(_next is null)
			_next = rhs;
		else
			_next.append(rhs);
	}

	protected {
		Chain!(T)	_next;
	}
}
